%Take the coefficients of variables that don't have, for construction, any divisor then build an eqation with them.
%
%Prototype: [theCoefficient] = generateCoefficientEquationFromString(chr)
%
%Input:  chr - Char equation.
%
%Output: theCoefficient - String of coefficient.

function [ theCoefficient ] = generateCoefficientEquationFromString( chr )

chr = strrep(chr, ' ', '');
chr = strrep(chr, '+', ' +');
chr = strrep(chr, '-', ' -');
pieces = strsplit(' ',chr);
if cellfun(@isempty, pieces(1))
    pieces(1) = [];
end

i = 1;
index = 1;
coefficient = pieces(1);
found = false;
while i <= length(pieces)
    actualPiece = pieces(i);
    if cellfun(@isempty,strfind(actualPiece,'/'))==true
        coefficient(index) = actualPiece;
        index = index+1;
        found = true;
    end
    i = i + 1;
end

if found == true
    theCoefficient = char(coefficient(1));
    match = 2;
    while match <= length(coefficient)
        theCoefficient = strcat(theCoefficient,char(coefficient(match)));
        match = match + 1;
    end
else
    theCoefficient = 0;
end

return;

end
